home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
kermit.columbia.edu
/
kermit.columbia.edu.tar
/
kermit.columbia.edu
/
newsgroups
/
misc.20031118-20041115
/
000218_fdc@columbia.edu_Sat Apr 17 14:11:15 2004.msg
< prev
next >
Wrap
Text File
|
2004-11-14
|
5KB
|
107 lines
Path: newsmaster.cc.columbia.edu!not-for-mail
From: Frank da Cruz <fdc@columbia.edu>
Newsgroups: comp.os.linux.misc,comp.protocols.kermit.misc
Subject: Re: logging data from com-port to a file
Date: 17 Apr 2004 18:09:50 GMT
Organization: Columbia University
Lines: 90
Message-ID: <slrnc82sne.2aq.fdc@sesame.cc.columbia.edu>
References: <c5rav3$vnt$1@newsreader1.utanet.at> <40814a75$0$17263$a1866201@newsreader.visi.com> <c5ri2b$4p1$1@newsreader1.utanet.at> <40815dad$0$17253$a1866201@newsreader.visi.com> <c5rn96$84g$1@newsreader1.utanet.at>
Reply-To: fdc@columbia.edu
NNTP-Posting-Host: sesame.cc.columbia.edu
X-Trace: newsmaster.cc.columbia.edu 1082225390 29232 128.59.59.56 (17 Apr 2004 18:09:50 GMT)
X-Complaints-To: postmaster@columbia.edu
NNTP-Posting-Date: 17 Apr 2004 18:09:50 GMT
User-Agent: slrn/0.9.8.0 (SunOS)
Xref: newsmaster.cc.columbia.edu comp.os.linux.misc:628716 comp.protocols.kermit.misc:14934
On 2004-04-17, z3r0c00l <z3r0c00l@utanet.at> wrote:
: Grant Edwards wrote:
:> In article <c5ri2b$4p1$1@newsreader1.utanet.at>, z3r0c00l wrote:
:>>>>hi, i need a tool which i can log data from the com-port to a file
:>>>>(it should log immediatly)
:>>>>does anybody know?
:>>>
:>>>$ cat /dev/ttyS1 >logfile
: ...
:>>i tried this before, but it didn't really work
:
:> Then you're going to have to cough up a few details about what
:> you're trying to do, what you've tried, and what you mean by
:> "didn't really work".
:>
: i tried to catch data from a siemens telephone
: first it didn't work, then i also ran some other software and suddenly
: the data was split up between the cat and the other software, but when i
: ran cat only, it didn't receive any data, so i didn't try cat any more
:
Use C-Kermit:
http://www.columbia.edu/kermit/ckermit.html
Here's a little script, that takes advantage of a new feature of C-Kermit
8.0.211, released just a few days ago (INPUT /NOMATCH). Replace the device
name and other parameters as needed, or make them parameters:
#!/p/kd/fdc/solaris9/wermit +
#
.port := /dev/ttyS1 # Serial port to use
if >= \v(argc) 2 { # Take log file name from command line
.file := \%1
} else { # Prompt for it if not given
while not def file {
ask file " Log file name: "
}
}
if not writeable \m(file) { # Make sure it's writeable
exit 1 "\m(file): Not writeable"
}
set modem type none # No modem is involved
set port /dev/ttyS1 # Or whatever port you are using
if fail { # Check that port was obtained
exit 1 \m(port): \v(setlinemsg)
}
set speed 9600 # Or whatever speed is needed
set flow rts/cts # Or Xon/Xoff, or None
set parity none # Or Even, Mark, Space, or Odd as needed
set session-log text # (see below)
log session \m(file) # Start the session log
if fail exit 1 # Make sure this worked
input /nomatch 23:59:59 # Log until midnight
if fail { # Catch i/o errors
exit 1 "\m(port): I/O error"
}
close session # Close the log
exit 0
Various session-log formats are available. To find out what they are,
type "help set session-log" at the C-Kermit> prompt, and see:
Syntax: SET SESSION-LOG { BINARY, DEBUG, TEXT, TIMESTAMPED-TEXT }
If BINARY, record all CONNECT characters in session log. If TEXT, strip
out CR, NUL, and XON/XOFF characters. DEBUG is the same as BINARY but
also includes Telnet negotiations on TCP/IP connections.
TIMESTAMPED-TEXT, as the name implies, is text but with timestamps placed
at the beginning of each line.
The INPUT command is what reads and logs the incoming material. Type
HELP INPUT and HELP SET INPUT to find out parameters and options. In this
case it simply reads incoming material and logs it until the given time
of day. Thus you could use the above script in a cron job to keep a daily
log of of your PBX. Or hourly, or whatever else you wanted.
For more about session logging, type "help log". Note that the session
can be not only a file, but also a pipe.
For more about Kermit scripting, see the tutorial here:
http://www.columbia.edu/kermit/ckscripts.html
For a tutorial on C-Kermit itself, see:
http://www.columbia.edu/kermit/ckututor.html
Frank da Cruz
The Kermit Project
Columbia University